
import { RECEIVE_ADDRESS, RECEIVE_CATEGORYS, RECEIVE_SHOPS ,USER_INFO} from './mutation-types'


import {reqAddress, reqCategorys, reqShops,reqPwdLogin,reqPhoneLogin} from '../api/index'
export  default {
     async  getCategorys(context) {
         let result=  await reqCategorys();
        //  console.log(result.data);
         let categorys=result.data
        context.commit(RECEIVE_CATEGORYS,categorys)
    },

    async getShops( context,shopData){   //shopData 是一个经纬度 对象

        let result =await reqShops(  shopData )
        console.log(result.data)
        let shops=result.data;
        context.commit(RECEIVE_SHOPS,shops)

    },

   //登录 获取用户信息
       async  asyncgetuserLogin(context,userInfos) {
         let  userInfo=   await reqPwdLogin(userInfos)

        context.commit(USER_INFO,userInfo.data)
       },

        // 手机号码短信验证登录 
        async  asyncPhoneLogin(context,dataPhone) {
            alert(111)
            let   userInfo =await  reqPhoneLogin(dataPhone);
            console.log(userInfo)
            if(userInfo.code===0) {
               context.commit(USER_INFO,userInfo.data)
            }
      }

}

